using System.Windows.Forms;
using Belmost4PDA.Constants;
using Belmost4PDA.Fasade;

namespace Belmost4PDA.Logic
{
    public class Control_EditBox : Control_PanelControl
    {
        private readonly HintTextBox textBox;
        public Control_EditBox(PanelItem panelItem)
            : base(panelItem)
        {
            textBox = new HintTextBox();
            textBox.Tag = panelItem;
            if (panelItem.charLenght != 0)
            {
                textBox.MaxLength = panelItem.charLenght;
            }
            else if (panelItem.numfraction == 0)
                textBox.MaxLength = panelItem.numallLenght;
            else textBox.MaxLength = panelItem.numallLenght + 1;
        }
        public override string GetControlType()
        {
            return ControlType.EditBox;
        }

        public override AbstractMapper GetMapper()
        {
            return new Mapper_EditBox(this);
        }

        public override Control GetFormControl()
        {
            return textBox;
        }

        public override string GetCaption()
        {
            return ((PanelItem) textBox.Tag).Caption;
        }
    }
}
